package day7;

import java.util.Scanner;

/**
 * 比赛求平均数
 * 去掉一个最大值一个最小值，对剩下的评分求平均数
 */
public class CalTotalAvg {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("一共有几位评委:");
        int length = sc.nextInt();
        double[] arr = enterData(length);
        calTotalAvg(arr);

    }


    public static double[] enterData(int length){
        Scanner sc = new Scanner(System.in);
        double[] arr = new double[length];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"位评委的分数");
            arr[i] = sc.nextDouble();
        }
       // Arrays.sort(arr);
        return arr;
    }


    public static void calTotalAvg(double[] arr){
        double count =0;
        double sum = 0;
        double avg ;
        for (int i = 1; i < arr.length-1; i++) {
            sum+=arr[i];
            count+=1;
        }
        System.out.println("总分为:"+sum);
        avg = sum/count;
        System.out.println("平均分为："+avg);
    }


   /*
    public static void calTotalAvg(double[] arr){
        double count =0;
        double sum = 0;
        double avg = 0;
        double max = arr[0];
        double min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max<arr[i]){
                max = arr[i];
            }
            if (min>arr[i]){
                min = arr[i];
            }
            sum += arr[i];
        }

    }

    */

}
